package com.crm.service.impl.common;


import com.crm.common.model.Enum.StatusCodeEnum;
import com.crm.dao.mapper.sys.FileUploadMapper;
import com.crm.model.entity.sys.FileUpload;
import com.crm.service.common.FileUploadDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author luojie
 * @date 2020/12/21 16:25
 */
@Service
public class FileUploadDbServiceImpl implements FileUploadDbService {

    @Autowired
    FileUploadMapper fileUploadMapper;

    @Override
    public Boolean insertFileUpload(FileUpload fileUpload) {
        Boolean result = false;
        int num = fileUploadMapper.insert(fileUpload);
        if(num>0){
            result = true;
        }
        return result;
    }

    @Override
    public FileUpload selectFileUploadById(String id) {
        FileUpload fileUpload = fileUploadMapper.selectByPrimaryKey(id);
        return fileUpload;
    }

    @Override
    public Boolean deleteFileUploadById(String id) {
        FileUpload fileUpload = new FileUpload();
        fileUpload.setUploadId(id);
        fileUpload.setDeleteStatus((short) StatusCodeEnum.DELETE_CODE.getState());
        int num = fileUploadMapper.updateByPrimaryKeySelective(fileUpload);
        return num > 0;
    }
}
